<?php
//The following line creates the new xmlwriter object...
$xml = new XmlWriter();
//Allocates space to build up the xml object
$xml->openMemory();
//xml meta data...
$xml->startDocument('1.0','UTF-8');
//creates a log tag
$xml->startElement('log');
//creates a title tag,writes data between the tags,and closes it..
$xml->writeElement('title','this is a test post');
//Similar to the previous one
$xml->writeElement ('tag','test');
$xml->writeElement('time','insert time data from db');
//creates a dummy tag,Cdata doesn't seem to work without creating a dummy tag..
$xml->startElement('cd');
//write Cdata
$xml->writeCData('This is a test text');
//closes all the tags opened so far
$xml->endElement();
$xml->endElement();
//closes the document
$xml->endDocument();
//sets the content type header as the default is text/html
header('Content-type: text/xml');          
//prints the xml object to the page
echo $xml->outputMemory(true);
?>
